package demo2;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/resp")
public class TestResponse extends HttpServlet {
    @Override
    protected void doGet(
            HttpServletRequest req, HttpServletResponse resp
            )throws ServletException, IOException{
        resp.setContentType("text/html;charset=UTF-8");
//        resp.setStatus(Integer.parseInt("888"));
        //设置错误码和错误信息
//        resp.sendError(Integer.parseInt("888"),"888表示权限不足");
//        resp.getWriter().write("响应状态码设置成功");
        resp.getWriter().write("字符编码设置成功");
    }
}
